﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DevExpress.Web.ASPxEditors;
using DevExpress.Web.ASPxGridView;
using DevExpress.Web.ASPxClasses.Design;
using DevExpress.Web.ASPxEditors.Design;
using System.Web.Security;

namespace App.lib.controls
{
    [DefaultProperty("Text")]
    [ToolboxData("<{0}:QLoqout runat=server></{0}:QLoqout>")]
    [TypeConverter(typeof(ExpandableObjectConverter))]
    public class QLoqout : ASPxButton
    {

        private Uri navigateUrl;

        public Uri NavigateUrl
        {
            get { return navigateUrl; }
            set { navigateUrl = value; }
        }
        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);
            this.Click += new EventHandler(OnClick);
        }
        private void OnClick(object obj, EventArgs ergs)
        {
            FormsAuthentication.SignOut();
            HttpContext.Current.Session.Abandon();
            if (navigateUrl != null)
            {
                HttpContext.Current.Response.Redirect(navigateUrl.ToString(), true);
            
            }
        }
        protected override void Render(HtmlTextWriter writer)
        {
            base.Render(writer);
        }
        
    }
}
